#{extends 'admin.html' /}

#{set 'moreStyles' }
	#{css 'listResult', output:'all'/}
#{/set}

#{set 'moreScripts' }
	#{js 'jquery-1.9.1.js', output:'all'/}
	#{js 'listResult.js', output:'all'/}
#{/set}

<div>

#{form action:@listResult().add('order', order ).add('orderBy', orderBy), method:'GET'}
	<div class="advancedSearch">
		<div>
			<label>&{'result.label.inGoogle'}: 
				<select name="inGoogle" id="inGoogle">
				  <option value="&{'result.filter.selectOption'}">&{'result.filter.selectOption'}</option>
				  <option value="&{'result.filter.yes'}">&{'result.filter.yes'}</option>
				  <option value="&{'result.filter.no'}">&{'result.filter.no'}</option>
				  <option value="&{'result.filter.maybe'}">&{'result.filter.maybe'}</option>
				</select>
			</label>
			<label>&{'result.label.www'}: 
				<select name="www" id="www">
				  <option value="&{'result.filter.selectOption'}">&{'result.filter.selectOption'}</option>
				  <option value="&{'result.filter.y'}">&{'result.filter.y'}</option>
				  <option value="&{'result.filter.n'}">&{'result.filter.n'}</option>
				</select>
			</label>

			<label>&{'result.label.pr'}:
				<input type="text" name="pr" value="${pr}" />
			</label>
		</div>
		<div>
			<label>&{'result.label.refDomains'}:
				<input type="text" name="refDomians" value="${refDomians}" />
			</label>
			<label>&{'result.label.refIp'}:
				<input type="text" name="refips" value="${refips}" />
			</label>
			<label>&{'result.label.refSubnet'}:
				<input type="text" name="refsubnet" value="${refsubnet}" />
			</label>
		</div>		
		<div>
			<label>&{'result.label.extbackLinksEdu'}:
				<input type="text" name="extlinksedu" value="${extlinksedu}" />
			</label>
			<label>&{'result.label.redDomainsEdu'}:		
				<input type="text" name="refdomainedu" value="${refdomainedu}" />
			</label>
			<label>&{'result.label.extBackLinksGov'}:
				<input type="text" name="extbacklinksgov" value="${extbacklinksgov}" />
			</label>
		</div>
		<div>
			<label>&{'result.label.refDomiansGov'}:
				<input type="text" name="refdomiansgov" value="${refdomiansgov}" />
			</label>
			<label>&{'result.label.refDomainsHome'}:
				<input type="text" name="refdomainshome" value="${refdomainshome}" />
			</label>
			<label>&{'result.label.percentHomepage'}:
				<input type="text" name="percenttoh" value="${percenttoh}" />
			</label>
		</div>	
		
		<input type="submit" value="&{'crud.search'}" /> &{'result.label.leyend.example'}	
	</div>
	#{/form}
	
	<div style="clear: left">
		#{form action:@searchWithProxy(), enctype:'multipart/form-data', method:'POST'}
			Proxies 
			<select name="proxy">
				#{list proxies, as:'proxy'}
					<option value="${proxy.id}">${proxy}</option>
				#{/list}
			</select> 
			<input type="hidden" name="order" value="${order}">
			<input type="hidden" name="orderBy" value="${orderBy}">
			<input type="submit" name="submit" value="search in Google">
		#{/form}
	</div>
	
	<div id="resultList" class="result">
	
	    <h2 id="resultListTitle">&{'result.label.tittle'}</h2>
	
		<table>
			<thead>
				<th>Selected<input type="checkbox" id="superDelete" onclick="deleteAll()"></th>
				<th class="sitename"><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','site')}">&{'result.label.domain'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','pr')}">&{'result.label.pr'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','ingoogle')}">&{'result.label.inGoogle'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','www')}">&{'result.label.www'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refdomain')}">&{'result.label.refDomains'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refips')}">&{'result.label.refIp'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refsubnet')}">&{'result.label.refSubnet'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','extlinksedu')}">&{'result.label.extbackLinksEdu'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refdomainedu')}">&{'result.label.redDomainsEdu'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','extbacklinksgov')}">&{'result.label.extBackLinksGov'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refdomiansgov')}">&{'result.label.refDomiansGov'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','refdomainshome')}">&{'result.label.refDomainsHome'}</a></th>
				<th><a href="@{listResult().add('order',(order == 'DESC' ? 'ASC' : 'DESC')).add('orderBy','percenttoh')}">&{'result.label.percentHomepage'}</a></th>	
				<th>Good to Buy</th>		
			</thead>
			<tbody>
				#{list results, as:'result'}
				<tr>
					  <td><input type="checkbox" id='${result.site}' class="deleted" #{if result.deleted} checked="true" #{/if} onclick="deleteItem('${result.site}');" ></td>
					  <td>${result.site}</td>
					  <td>#{if result.pr == -1}N/A#{/if}#{else}${result.pr}#{/else}</td>
					  <td>
					  	#{if result.inGoogle == 'MAYBE'}
					  		<select id='domain_${result_index}' onchange="setInGoogle('${result.site}', $('#domain_${result_index} :selected').val())">
					  			<option #{if result.inGoogle == 'YES'}selected#{/if}>YES</option>
					  			<option #{if result.inGoogle == 'NO'}selected#{/if}>NO</option>
					  			<option #{if result.inGoogle == 'MAYBE'}selected#{/if}>MAYBE</option>
					  		</select>
					 	 <a href='http://www.google.com/search?q=site:${result.site}' target="_blank"><img src="/public/images/search-icon.png" alt='Search In Google'></a>#{/if}
					 	 #{else}
					 	 	${result.inGoogle}
					 	 #{/else}
					  </td>
					  <td>${result.www}</td>
					  <td>${result.refDomians}</td>
					  <td>${result.refIps}</td>
					  <td>${result.refSubNet}</td>
					  <td>${result.extBackLnksEdu}</td>
					  <td>${result.refDomainsEdu}</td>
					  <td>${result.extBackLinksGov}</td>
					  <td>${result.refDomainsGov}</td>				  
					  <td>${result.refDomianHome}</td>
					  <td>${result.percentToHome}</td>
					  <td><input type="checkbox" #{if result.goodToBuy}  checked="true" #{/if} onclick="goodToBuy('${result.site}');"></td>	
				</tr>
				#{/list}
			</tbody>
		</table>
	</div>
</div>

<a href="@{DomainsController.deleteSelection(orderBy, order)}">Delete Selection</a>  
<a href="@{DomainsController.createXLSFile()}">Export Result</a>   

<script>
if ('${inGoogle}'!='')
	$('#inGoogle option:contains(${inGoogle})').prop('selected', true);
if ('${www}'!='')	
	$('#www option:contains(${www})').prop('selected', true);
</script>